package com.recruit.g1.jobmetting.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.recruit.g1.pojo.jobmetting.entity.JobMeeting;
import com.recruit.g1.pojo.jobmetting.vo.JobMettingListVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface JobMeetingMapper extends BaseMapper<JobMeeting> {
    @Insert("INSERT INTO jobmeeting(user_contact,meeting_name,time,location,description,start_time) VALUES (#{userContact},#{meetingName},#{time},#{location},#{description},#{startTime})")
    void add(JobMeeting jobMeeting);

    @Select("<script>SELECT id,\n" +
            "               user_contact,\n" +
            "               meeting_name,\n" +
            "               start_time,\n" +
            "               location,\n" +
            "               description\n" +
            "        FROM jobmeeting\n" +
            "        <where>\n" +
            "            <if test=\"meetingName!='' and meetingName!=null\">\n" +
            "                AND meeting_name LIKE CONCAT('%', #{meetingName}, '%')\n" +
            "            </if>\n" +
            "            <if test=\"location!='' and location!=null\">\n" +
            "                AND location LIKE CONCAT('%', #{location}, '%')\n" +
            "            </if>\n" +
            "        </where>\n" +
            "    </script>")
    List<JobMettingListVO> jobMeetingList(@Param("meetingName") String meetingName,
                                          @Param("location") String location);
}
